package com.inspectortime.service;

import java.util.Iterator;
import java.util.List;

import junit.framework.TestCase;

public class ZipCodeSearchServiceImplTestOld extends TestCase {

	public void testLookupZip() throws Exception {
		ZipCodeInfo info = service.lookupZipCode("30341");
		assertTrue(info.getStateCode().equals("GA"));
	}
	
	public void testDistanceCalc() throws Exception {
		double dist = service.findDistanceInMiles("30341", "30050");
		assertTrue(dist > 19 && dist < 20);
	}
	
	public void testNearbyZipSearch() throws Exception {
		List list = service.findNearbyZipCodes("30341", 4);
		assertEquals(5, list.size());
		ZipCodeInfo originalZip = (ZipCodeInfo) list.iterator().next();
		assertEquals("30341", originalZip.getZipCode());
		assertEquals(0.0, originalZip.getOptionalDistanceToSource());
		assertEquals(33.89010238647461, originalZip.getLatitude());
	}
	
	ZipCodeSearchService service = new DomZipCodeSearchServiceImpl();
	
	public void testNearbyZipSearch500() throws Exception {		
		List list = service.findNearbyZipCodes("30341", 99);
		Iterator iter = list.iterator();
		ZipCodeInfo originalZip = (ZipCodeInfo) iter.next();
		assertEquals("30341", originalZip.getZipCode());
		assertEquals(0.0, originalZip.getOptionalDistanceToSource());
		assertEquals(33.89010238647461, originalZip.getLatitude());
		ZipCodeInfo nextZip = (ZipCodeInfo) iter.next();
		assertEquals("30340", nextZip.getZipCode());
	}

	/*
	public void testMany() throws Exception {
		for (int i = 0; i < 10; i++) {
			testNearbyZipSearch500();
		}
	}
	*/
	
}
